package com.haierCamera.customapplication.api.repo;

import androidx.lifecycle.LiveData;

import com.haierCamera.customapplication.api.ApiService;
import com.haierCamera.customapplication.api.vo.GetCameraStatus;
import com.haierCamera.customapplication.api.vo.GetUserInfoResponse;
import com.haierCamera.customapplication.api.vo.LoginResponse;
import com.haierCamera.customapplication.api.vo.TXOauth;
import com.haierCamera.customapplication.api.vo.Token;
import com.haierCamera.customapplication.common.Resource;
import com.haierCamera.customapplication.utils.ResourceConvertUtils;

import javax.inject.Inject;
import javax.inject.Singleton;

/**
 * @author yawei
 * @data on 2018/8/3 下午2:53
 * @email zyawei@live.com
 */
@Singleton
public class RegisterRepo {
    private ApiService apiService;

    @Inject
    public RegisterRepo(ApiService apiService) {
        this.apiService = apiService;
    }

    public LiveData<Resource<Object>> getRegister(String mobile, String vcode, String pwd) {
        return ResourceConvertUtils.convertToResource(apiService.getRegister(mobile, vcode, pwd));
    }

    public LiveData<Resource<Object>> getVcode(String mobile) {
        return ResourceConvertUtils.convertToResource(apiService.getVcode(mobile));
    }

    public LiveData<Resource<Object>> forget(String mobile, String vcode, String pwd) {
        return ResourceConvertUtils.convertToResource(apiService.forget(mobile, vcode, pwd));
    }

    public LiveData<Resource<LoginResponse>> login(String mobile, String pwd) {
        return ResourceConvertUtils.convertToResource(apiService.login(mobile, pwd));
    }

    public LiveData<Resource<TXOauth>> oauth(String oauthType, String oauthCode, String nick, String head) {
        return ResourceConvertUtils.convertToResource(apiService.oauth(oauthType, oauthCode, nick, head));
    }

    public LiveData<Resource<Token>> bindingWX(String oauthCode, String mobile, String vcode) {
        return ResourceConvertUtils.convertToResource(apiService.bindingWX(oauthCode, mobile, vcode));
    }

    public LiveData<Resource<Object>> removeWX(String oauthType) {
        return ResourceConvertUtils.convertToResource(apiService.removeWX(oauthType));
    }

    public LiveData<Resource<GetUserInfoResponse>> getUserInfo() {
        return ResourceConvertUtils.convertToResource(apiService.getUserInfo());
    }

    public LiveData<Resource<GetCameraStatus>> getCameraStatus(String serialNumber, String channelNo, String enableType) {
        return ResourceConvertUtils.convertToResource(apiService.getCameraStatus(serialNumber, channelNo, enableType));
    }

    public LiveData<Resource<Object>> setCameraStatus(String serialNumber, String channelNo, String enableType, String enable) {
        return ResourceConvertUtils.convertToResource(apiService.setCameraStatus(serialNumber, channelNo, enableType, enable));
    }
}
